﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Entity;

namespace BLL
{
    public class ModuleService
    {
        private RolesDAL roleDAL = new RolesDAL();
        public ModuleVo getAllModules()
        {
            ModuleVo moduleVo = new ModuleVo();
            moduleVo.ModuleID = null;
            moduleVo.MOduleName = "root";
            moduleVo.DisplayName = "竞赛管理系统";
            moduleVo.ModuleURL = "#";
            moduleVo.getChildren();
            return moduleVo;
        }

        public ModuleVo getTeacherModules(string teacherId)
        {
            TeacherVo teacher = new TeacherVo();
            teacher.TeacherId = teacherId;
            IList<BoRoles> roles = roleDAL.GetRolesByeTeacher(teacherId);
            List<RoleVo> rvs = new List<RoleVo>();
            foreach (BoRoles r in roles)
            {
                RoleVo rv = new RoleVo();
                rv.RoleId = r.ROL_ID;
                rvs.Add(rv);
            }
            teacher.Roles = rvs;

            return teacher.getAuthorizedModules();
        }
    }
}
